/* 
 * File:   QShortcutGrabber.h
 * Author: jcrada
 *
 * Created on April 12, 2009, 6:18 PM
 */

#ifndef _QSHORTCUTGRABBER_H
#define	_QSHORTCUTGRABBER_H

#include <QtGui/QPlainTextEdit>
#include <QtGui/QKeyEvent>
#include <QtGui/QKeySequence>

namespace jcrada {

    class QShortcutGrabber : public QPlainTextEdit{
        Q_OBJECT
    signals:
        void keyPressed( int key );
    protected:

        virtual void keyPressEvent( QKeyEvent *e ) {
            emit keyPressed(e->key());
            QKeySequence key(e->key());
            clear();
            appendPlainText(key.toString());
            e->accept();
        }

      
    public:

        QShortcutGrabber( QWidget *parent = NULL ) : QPlainTextEdit( parent ) {

        }
    };
}

#endif	/* _QSHORTCUTGRABBER_H */

